package com.gree.syq.wifidemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class DemoActivity extends Activity {
    private final static String TAG = "DemoActivity";

    private Button mAirconditrion;
    private Button mRemote;
    private static TextView mTextView;
    private Activity activity = this;

    private DemoApplication application;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo);

        // add necessary intent values to be matched.
        application = (DemoApplication) getApplication();
        mRemote = (Button) this.findViewById(R.id.remoteButton);
        mRemote.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                application.setState(1);
                application.mState = RemoteRole.getInstance(getApplicationContext());
                application.mState.init(activity);
                DemoLog.getInstance().logi("STATE:Remote:");
            }
        });


        mAirconditrion = (Button) this.findViewById(R.id.ariconditionButton);
        mAirconditrion.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                application.setState(2);
                application.mState = AirConditionRole.getInstance(getApplicationContext());
                application.mState.init(activity);
                DemoLog.getInstance().logi("STATE:Airconditrion:");
            }
        });

        mTextView = (TextView) findViewById(R.id.logText);
        mTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
        DemoLog.getInstance().setTextView(mTextView);
    }

    /**
     * register the BroadcastReceiver with the intent values to be matched
     */
    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}
